<?php


namespace Facade;


class Client
{
    public static function main()
    {
        // 创建门面类
        $facade = new Facade();

        // 由门面类去调度子系统执行具体的操作
        $facade->operation();
    }
}


/**
 * 外观角色
 * Class Facade
 * @package Facade
 */
class Facade
{
    protected SubSystem1 $subsystem1;
    protected SubSystem2 $subsystem2;
    protected SubSystem3 $subsystem3;

    public function __construct()
    {
        $this->subsystem1 = new SubSystem1();
        $this->subsystem2 = new SubSystem2();
        $this->subsystem3 = new SubSystem3();
    }

    public function operation(): void
    {
        $this->subsystem1->operation1();
        $this->subsystem2->operation2();
        $this->subsystem3->operation3();
    }
}

/**
 * 子系统角色
 */
class SubSystem1
{
    public function operation1(): void
    {
        echo 'subsystem1 operation', PHP_EOL;
    }
}
class SubSystem2
{
    public function operation2(): void
    {
        echo 'subsystem2 operation', PHP_EOL;
    }
}
class SubSystem3
{
    public function operation3(): void
    {
        echo 'subsystem3 operation', PHP_EOL;
    }
}


Client::main();
